-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
split skb as soon http_parser returned TFW_PASS #1134
Conversation
If ss_skb_split() fails, a part of the next http message will be added to the end of last parsed message. If the error happened, there is no recourse, we must close the connection.
4b1faed
to
b024333
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, with minor comments corrections.
@@ -1894,40 +1894,17 @@ tfw_http_conn_send(TfwConn *conn, TfwMsg *msg) | |||
* Siblings in HTTP are pipelined HTTP messages that share the same SKB. | |||
*/ | |||
static TfwHttpMsg * | |||
tfw_http_msg_create_sibling(TfwHttpMsg *hm, struct sk_buff **skb, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like function comment is outdated: @msg
-> @hm
.
tempesta_fw/http.c
Outdated
/* | ||
* The message is fully parsed, the rest of the data in the | ||
* stream may represent another request or its part. | ||
* If skb splitting has failed, the request cant be forwarded to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cant
-> can't
. The same for tfw_http_resp_process()
.
tempesta_fw/http.c
Outdated
@@ -3247,6 +3249,26 @@ tfw_http_resp_process(TfwConn *conn, const TfwFsmData *data) | |||
goto bad_msg; | |||
} | |||
|
|||
/* | |||
* The message is fully parsed, the rest of the data in the | |||
* stream may represent another request or its part. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
request
-> response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch and good to merge the change after fix of the skb
leak in tfw_http_req_process()
.
* process current one. But @skb must be freed then, since it's | ||
* not owned by any message. | ||
*/ | ||
if (!req_conn_close && skb) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If req_conn_close
and skb != NULL
(i.e. there are pipelined messages), then the skb leaks - nobody frees it.
4f65bde
to
72ba622
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to merge
If ss_skb_split() fails, a part of the next http message will be added to the end of last parsed message. Forwarding such message will break response-request sequence. There is no sense to process the parsed message if split will fail: such message can't be forwarded and connection must be closed to recover.
Current master is also vulnerable for attack on response-request sequence attack:
Connection: close
headerConnection: close
header is not set. So no split is performed.